import datetime
from .db import cursor, conn
from utils.print_message import print_message

# 获取所有平台的相关数据
def select_all_model_and_platform():
    sql = f"""
    SELECT
        m.id as llm_id,
        m.model_name,
        p.platform_name,
        p.tag_name,
        p.home_url
    FROM
        llm_info m
    JOIN
        platform_info p ON m.platform_id = p.id
    WHERE 
        m.is_enabled = 1;
    """
    cursor.execute(sql)
    return cursor.fetchall()

def select_model_and_platform_by_model_name(model_name):
    sql = """
    SELECT
        m.id AS llm_id,
        m.model_name,
        p.platform_name,
        p.tag_name,
        p.home_url
    FROM
        llm_info m
    JOIN
        platform_info p ON m.platform_id = p.id
    WHERE 
        m.model_name = %s AND m.is_enabled = 1;
    """
    cursor.execute(sql, (model_name,))
    return cursor.fetchone()

